//
//  HEMyReportCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/26.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEMyReportCell.h"
#import "HECheckReportModel.h"

@interface HEMyReportCell ()

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *checkTimeLb;
@property (nonatomic, strong) UILabel *checkAddressLb;

@end

@implementation HEMyReportCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = CLightGrayColor;

        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
 
    warp.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp.layer.shadowOffset = CGSizeMake(0,5);
    warp.layer.shadowOpacity = 1;
    warp.layer.shadowRadius = 6;
    warp.layer.cornerRadius = 10;
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
    
    UIImageView *logoView = [UIImageView new];
    logoView.contentMode = UIViewContentModeScaleAspectFill;
    logoView.image = IMAGE_NAMED(@"msg_exam");
    [warp addSubview:logoView];
  
    _titleLb = [UILabel new];
    _titleLb.text = @"脊柱检查";
    _titleLb.font = DYFont(16);
    _titleLb.textColor = CNavDargGrayColor;
    [warp addSubview:_titleLb];
    
    [logoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.left.equalTo(warp).mas_offset(15);
        make.width.mas_offset(20);
        make.height.mas_offset(25);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(logoView.mas_right).mas_offset(10);
        make.right.equalTo(warp).mas_offset(-15);
    }];
    
    UIView *headBottomLine = [UIView new];
    headBottomLine.backgroundColor = CSplitLineColor;
    [warp addSubview: headBottomLine];
    [headBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
        make.height.offset(1);
    }];
    
    // middle
    UILabel *timeTitlLb = [UILabel new];
    timeTitlLb.text = @"检查时间：";
    timeTitlLb.font = DYBlodFont(16);
    [warp addSubview: timeTitlLb];
    
    UILabel *addressTitlLb = [UILabel new];
    addressTitlLb.text = @"检查地点：";
    addressTitlLb.font = DYBlodFont(16);
    [warp addSubview: addressTitlLb];
    
    
    _checkTimeLb = [UILabel new];
    _checkTimeLb.text = @"脊柱检查";
    _checkTimeLb.font = DYFont(16);
    _checkTimeLb.textColor = CNavDargGrayColor;
    [warp addSubview:_checkTimeLb];
    
    _checkAddressLb = [UILabel new];
    _checkAddressLb.text = @"脊柱dddddddddd";
    _checkAddressLb.font = DYFont(16);
    _checkAddressLb.textColor = CNavDargGrayColor;
    _checkAddressLb.numberOfLines = 0;
    [warp addSubview:_checkAddressLb];
    
    [timeTitlLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headBottomLine.mas_bottom).offset(10);
        make.left.equalTo(headBottomLine.mas_left);
    }];
    [timeTitlLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
 
    [addressTitlLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(timeTitlLb.mas_bottom).offset(10);
        make.left.equalTo(headBottomLine.mas_left);
    }];
    [addressTitlLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    
    [_checkTimeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headBottomLine.mas_bottom).offset(10);
        make.left.equalTo(timeTitlLb.mas_right);
        make.right.equalTo(warp).offset(-10);
    }];
    
    [_checkAddressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_checkTimeLb.mas_bottom).offset(10);
        make.left.equalTo(addressTitlLb.mas_right);
        make.right.equalTo(warp).offset(-10);
    }];
     
    
    //  footer
    UIView *footerTopLine = [UIView new];
    footerTopLine.backgroundColor = CSplitLineColor;
    [warp addSubview: footerTopLine];
    [footerTopLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_checkAddressLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
        make.height.offset(1);
    }];
    
    UILabel *checkLb = [UILabel new];
    checkLb.text = @"立即查看";
    checkLb.font = DYFont(16);
    checkLb.textColor = CNavLightBlackColor;
    [warp addSubview: checkLb];
    
    [checkLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(footerTopLine.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.bottom.equalTo(warp.mas_bottom).offset(-15);
    }];
    
    UIImageView *_arrowView = [UIImageView new];
    _arrowView.contentMode = UIViewContentModeScaleAspectFill;
    _arrowView.image = IMAGE_NAMED(@"go_gray");
    [warp addSubview:_arrowView];
    
    [_arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(checkLb);
        make.right.equalTo(warp).mas_offset(-15);
        make.width.mas_offset(8);
        make.height.mas_offset(12);
    }];
    
}

- (void)configCellWithModel:(HECheckReportModel *)model {
    _checkTimeLb.text = model.Ktmsec;
    _checkAddressLb.text = model.service_addr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
